package org.dorm.learn;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Properties;

/**
 * add description here
 *
 * @author : dormi330
 * @version : 1.0
 */
public class CreateProp {

    public static void main(String[] args) {
        String relPath = CreateProp.class
                .getProtectionDomain()
                .getCodeSource()
                .getLocation()
                .getFile();
        System.out.println("relPath = " + relPath);
        File file = new File(relPath, "create/aa.properties");
        // 创建的文件在 classpath下

        try (OutputStream output = new FileOutputStream(file)) {
            Properties prop = new Properties();
            prop.setProperty("x", "hello\\.*");
            prop.setProperty("y", "abc//*.");
            prop.setProperty("z", "中文");

            // save properties to project root folder
            prop.store(output, null);
            System.out.println(prop);
        } catch (IOException io) {
            io.printStackTrace();
        }
    }
}
